<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/Store/Public/layui/css/layui.css"></link>
<link type="text/css" rel="stylesheet" href="/Store/Public/Admin/css/H-ui.css"/>
<link type="text/css" rel="stylesheet" href="/Store/Public/Admin/css/H-ui.admin.css"/>
<link type="text/css" rel="stylesheet" href="/Store/Public/Admin/font/font-awesome.min.css"/>
<script type="text/javascript" src="/Store/Public/Admin/js1/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="/Store/Public/layer/layer.js"></script>

<title>添加用户</title>
</head>
<body>
<div class="pd-20">
  <div class="Huiform">
      <table class="table table-bg">
        <tbody>
          <tr>
            <th width="100" class="text-r"><span class="c-red">*</span> 用户名：</th>
            <td><input type="text" style="width:200px" class="input-text" value="" placeholder="" id="user-name" name="user-name" datatype="*2-16" nullmsg="用户名不能为空"></td>
          </tr>
          <tr>
            <th class="text-r">邮箱：</th>
            <td><input type="email" style="width:300px" class="input-text" value="" placeholder="" id="user-email" name="user-email"></td>
          </tr> 
          <tr>
             <th class="text-r">所属角色</th>
             <?php if($arr): if(is_array($arr)): foreach($arr as $key=>$v): ?><table >
                          <input type="checkbox" name="role_ids[]" value="<?php echo ($v["id"]); ?>" id="checkbox" style="margin-left:120px"/>
                            <?php echo ($v["name"]); ?>
                      </table><?php endforeach; endif; endif; ?>
           </tr>
           </table>
        </tbody>
      
         &nbsp;&nbsp;&nbsp;&nbsp;
      <div class="layui-form-item">
          <div class="layui-input-block">
          <button class="layui-btn"lay-submit lay-fileter="formDemo" id="commit">提交</button>
          
      </div>
      </div>
  </div>
</div>

<script type="text/javascript">
$('#commit').click(function() {
	var name=$('#user-name').val();
	var email=$('#user-email').val();
	var role_ids=[];
		 $(':checkbox').each(function() {
			if($( this ).prop( 'checked' )) {
			  role_ids.push( $( this ).val() );
			}
		});
		
	$.post('/Store/index.php/Admin/User/add',{name:name,email:email,role_ids:role_ids},function(data) {
		if(data.pass==0){
			layer.msg(data.msg,{time:1000,icon:2},function(){
				location.reload();
			});
		}
		if(data.pass==1) {
			var index=layer.msg(data.msg,{time:1000,icon:1},function(){
				parent.layer.close(index);
				window.parent.location.reload();
			});
		}
	},'json')
	
	
})



</script>
</body>
</html>

<!--代码整理：js代码 www.jsdaima.com-->